#include "rclcpp/rclcpp.hpp"
#include "test_multi_array/msg/double_array.hpp"
#include "test_multi_array/msg/multi_array.hpp"

class MultiArrayNode : public rclcpp::Node {
public:
  MultiArrayNode() : Node("multi_array_node") {
    publisher_ = this->create_publisher<test_multi_array::msg::MultiArray>(
        "multi_array", 10);
    timer_ = this->create_wall_timer(
        std::chrono::milliseconds(1000),
        std::bind(&MultiArrayNode::timer_callback, this));
  }

  void timer_callback() {
    auto msg = test_multi_array::msg::MultiArray();
    msg.data = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    publisher_->publish(msg);
  }

private:
  rclcpp::Publisher<test_multi_array::msg::MultiArray>::SharedPtr publisher_;
  rclcpp::TimerBase::SharedPtr timer_;
};

int main(int argc, char *argv[]) {
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<MultiArrayNode>());
  rclcpp::shutdown();
  return 0;
}